Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check block_timestamp always increases. #638

Merged
merged 4 commits into from
Sep 19, 2024

Conversation

LindaGuiga
Copy link
Contributor

This PR aims at addressing #634.

In create_block_circuit, it range-checks diff = timestamp - parent_timestamp - 1 between 0 and 2ˆ32, as a way to ensure timestamp > parent_timestamp.

@github-actions github-actions bot added the crate: evm_arithmetization Anything related to the evm_arithmetization crate. label Sep 18, 2024
// In other words, we range-check `diff = timestamp - prev_timestamp - 1`
// between 0 and 2ˆ32.
let diff = builder.sub(timestamp, prev_timestamp);
let diff = builder.add_const(diff, F::NEG_ONE);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should do a minus 1 here. Timestamp is UNIX based, in seconds if I'm correct. If a chain were to have a block time of < 1 sec this check would fail. We should probably allow for 0 diff.

) {
// We check that timestamp >= prev_timestamp.
// In other words, we range-check `diff = timestamp - prev_timestamp`
// between 0 and 2ˆ32.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// between 0 and 2ˆ32.
// is between 0 and 2ˆ32.

@Nashtare Nashtare merged commit 466191b into develop Sep 19, 2024
17 checks passed
@Nashtare Nashtare deleted the check-timestamp-consistency branch September 19, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate: evm_arithmetization Anything related to the evm_arithmetization crate.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants